import axios from 'axios'
import React, { useEffect, useState } from 'react'
import ItemList from '../componens/ItemList'
import { Tabs } from 'antd';
function List() {
    const [list,setList]=useState([])
    const  getdata=async()=>{
        const res=await axios.get('/api/list')
        console.log(res.data);
        
        setList(res.data.data)
    }
    useEffect(()=>{
        getdata()
    },[])
    const onChange = key => {
        console.log(key);
        getdata(key)
      };
      const items = [
        {
          key: '1',
          label: '热搜榜',
          children: 'Content of Tab Pane 1',
        },
        {
          key: '2',
          label: '北京绑',
          children: 'Content of Tab Pane 2',
        },
        {
          key: '3',
          label: '民生榜',
          children: 'Content of Tab Pane 3',
        },
        {
            key: '4',
            label: '财经榜',
            children: 'Content of Tab Pane 4',
          },
      ];
  return (
    <div>
         <Tabs defaultActiveKey="1" items={items} onChange={onChange} />
       <h2>百度热搜 》</h2>

       <div>
          {
            list.map((v,i)=>{
                return <ItemList v={v} key={i}></ItemList>
            })
          }
       </div>
      
    </div>
  )
}

export default List
